home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 3.1 KB | 96 lines | [TEXT/GEOL] |
- Item 1199452 12-Nov-90 05:38PST
-
- From: POWERUP.ENG Power Up Software,PRT
-
- To: MACAPP.TECH$ MacApp Technical
-
- Sub: Streaming to the Resource
-
- Attn: MacApp.Tech$
- SentBy: James Plamondon
- Date 11/9/90
- Subject Streaming to the Resource F
- From James Plamondon
- To Larry Rosenstein
- CC MacApp.Tech$
-
- Subject: Streaming to the Resource Fork
- Dear Larry,
-
- I have a problem with streaming with which I was hoping you might be able to
- help me.
-
- My application displays pictures (among other things), and allows the user to
- copy and paste these pictures both between my app's documents and other
- applications. Each picture is described by an instance of a class, TPict,
- which has roughly the following interface:
-
- TPict = OBJECT(TStreamObject)
- fResID: INTEGER; { negative if document has no file (not yet
- saved) }
- fPicHandle: PicHandle; { must be non-nil if fResID is negative }
-
- { various methods, including ReadFrom() and WriteTo() }
- …
- END; { TPict }
-
- It is assumed that each picture will be stored as a PICT resource in the
- resource fork of one of our application's documents.
-
- The problem relates to the pasting of pictures into a document which has not
- yet been saved. I can't save the pictures in the document's file's resource
- fork; there's no such file, so there's no such resource fork.
-
- What I've tried doing is assigning unique negative ID's to each picture that
- is pasted into such a document. The negative ID signals that the picture is
- described only by the data in fPicHandle, and not by a resource on disk. When
- the document is saved, the following WriteTo() method is called for each
- picture:
-
- PROCEDURE TPict.WriteTo(
- aStream: TStream);
- OVERRIDE;
- VAR
- theResID: INTEGER;
-
- BEGIN
- theResID := abs(fResID);
-
- IF (Member(aStream, TFileStream)) & { streaming to a file — kludge!
- }
- (Get1Resource('PICT', theResID) = NIL) { PICT isn't there already }
- THEN
- BEGIN
- AddResource( { add the PICT to the file }
- Handle(fPicHandle),
- 'PICT',
- theResID,
- '');
- FailResError;
-
- fResID := theResID; { if not saved before, it's saved now }
- END; { if }
-
- aStream.WriteInteger(fResID);
- END; { WriteTo }
-
- This code seems like it ought to work, but it doesn't (famous last words!).
- It fails every time with a adResFailed error (-194) after the call to
- AddResource(). I've set all of the appropriate flags to signal that my
- documents need to write to the resource fork, but — alas — it doesn't fly.
-
- So, my questions for you, should you be so kind as to answer, are:
- • Is my basic approach sound, or is there a better, easier way to accomplish
- this goal?
- • Have you any idea how I could approach the problem of streaming a list of
- TPicts to the external scrap (given that only one PICT can be there at a
- time)?
- • Can you see any reason why the AddResource() call should fail as it does?
-
- With great appreciation for your assistance, I remain
-
- Yours,
-
- James Plamondon
-
-